//
// Created by wangjunjun on 2024/1/29.
//
#ifndef IMAGERECEIVER_H
#define IMAGERECEIVER_H


#include <QImage>
#include <QLabel>
#include <mutex>
#include <memory>
#include <unistd.h>
#include <QByteArray>
#include <opencv2/opencv.hpp>
#include <QObject>
#include <QDateTime>
#include <QTimer>
class CImageReceiver: public QObject
{
Q_OBJECT
public:
    //设置单例模式
    static std::shared_ptr<CImageReceiver>  GetInStance();

private:
    explicit CImageReceiver(QObject *parent = nullptr);
    ~CImageReceiver();
    void saveImage(const cv::Mat &image);
    cv::Mat decodeImage(std::vector<uchar> &data);
    QString getCurrentTime(); //获取当前时间
signals:
    void SendDisplaySignal(const cv::Mat &image); //send signal to show image
    void processData(const QByteArray &data);

public slots:
    /**
 * @brief: 图片的转化处理
 * @param[in]：data
 * */
    void receivedImage(const QByteArray &data);
    void  createDirectory(); //创建目录
private:
    static std::shared_ptr<CImageReceiver> m_InStance;
    static std::once_flag m_flag;
    QString m_Path;//返回文件路径
    QTimer* m_connectionTimer; //开启连接状态显示

};

#endif // IMAGERECEIVERTHREAD_H